package com.zyong.design.pattern.observer.case1;

/**
 * @program: zyong-design-pattern
 * @ClassName: ConcreteObserver
 * @author: zyong
 * @create: 2024-05-14 00:08
 */
public class ConcreteObserver implements Observer {
    private int observerState;
    private ConcreteSubject subject;

    public ConcreteObserver(ConcreteSubject subject) {
        this.subject = subject;

        this.subject.registerObserver(this);
    }

    @Override
    public void update() {
        observerState = subject.getState();
        System.out.println("Observer state updated: " + observerState);
    }
}
